<template>
	<view class="page-body">
		<web-view :src="data.url"></web-view>
	</view>
</template>

<script>
	import {
		baseURL,
		basePath
	} from '@/config/app'
	import {
		apiQuestionnaire
	} from "@/api/app";
	import Cache from "@/utils/cache";
	import {
		mapGetters,
		mapState
	} from 'vuex';
	import {
		INVITE_CODE
	} from '@/config/cachekey'
	export default {
		data() {
			return {
				data: '',
				type: '',
				url:{
					url:''
				},
				share:''
			};
		},
		onShow(options) {
			let pagearr = getCurrentPages();
			let currentPage = pagearr[pagearr.length - 1];
			this.type = currentPage.options.type;
			console.log("type值"+this.type)
			// this.url.url = currentPage.options.url;
			// console.log(decodeURIComponent(decodeURIComponent(currentPage.options.url)));
			this.url.url = decodeURIComponent(decodeURIComponent(currentPage.options.url));
			this.share = decodeURIComponent(decodeURIComponent(currentPage.options.share));
			console.log("type值"+this.url)
			console.log(this.isLogin);
			console.log('-----------');
			if (uni.getLaunchOptionsSync().scene) { //来源场景
				Cache.set('scene', uni.getLaunchOptionsSync().scene)
			}
			if (uni.getLaunchOptionsSync().query.invite_code) { //获取邀请码
				Cache.set(INVITE_CODE, uni.getLaunchOptionsSync().query.invite_code)
			}
			if (!this.isLogin) {
				this.$Router.push('/pages/login/login');
				this.$navto.navto('/pages/login/login');
				return false;
			}
			if (this.type == 1) {
				this.data = this.url;
				this.data.share_img=this.share;
			} else {
				this.$request.get(`shopapi/home/live_url`).then(res => {
					console.log(res.data);
					this.data = res.data.data;
				})
			}
		},
		onLoad() { //获取直播地址
			

		},
		computed: {
			...mapGetters(['userInfo'])
		},
		onShareAppMessage() {
			const {
				code
			} = this.userInfo
			const share = {
				title: this.data.title,
				path: `/bundle/pages/broadcast/broadcast?invite_code=${this.userInfo.code}&type=1&url=${encodeURIComponent(this.url.url)}`,
				imageUrl: this.data.share_img
			}
			return share
		},
		methods: {}
	};
</script>
<style>

</style>